# Basic settings
set -g default-terminal "xterm-256color"
set -sa terminal-features ',xterm-256color:RGB'
set -g mode-keys vi
set -g status-keys vi
set -g history-limit 64096
set -g escape-time 0
set -g clock-mode-style 24
set -g renumber-windows on
set -g focus-events on
set -gw mouse on
set -g set-titles on
set -g set-titles-string "#T"
set -g status-position top

# List of plugins
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-urlview'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'tmux-plugins/tpm'

## Catppuccin theme
set -g @catppuccin_flavour "mocha"
set -g @catppuccin_window_right_separator "█"
set -g @catppuccin_window_left_separator "█"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_middle_separator " | "
set -g @catppuccin_window_default_fill "none"
set -g @catppuccin_window_current_fill "all"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_current_text "#W"
set -g @catppuccin_status_modules_right "directory host date_time"
set -g @catppuccin_status_modules_left "user"
set -g @catppuccin_status_left_separator "█"
set -g @catppuccin_status_right_separator "█"
set -g @catppuccin_status_connect_separator "yes"
set -g @catppuccin_date_time_text "%H:%M:%S %d-%m-%Y"

## Everforest theme 
# set -g @tmux_everforest_date_format ' %d-%m-%Y'
# set -g @tmux_everforest_time_format '%H:%M:%S'
# set -g @tmux_everforest_prefix_highlight_pos 'L'
# run ~/.config/tmux/theme.tmux

# Modules
if-shell "uname -s | grep -q Darwin" {
  source-file "$HOME/.config/tmux/macos.conf"
}

# Key bindings
## Second prefix
set -g prefix2 C-]

## Reload settings
bind r source-file "$HOME/.config/tmux/tmux.conf"\; popup -E -h30% -w20% "cowsay 'Tmux reloaded!' & sleep 0.5"

## Clear history
bind -r l clear-history

## Set default directory for new windows in this session to current directory:
bind C-c attach-session -c "#{pane_current_path}"

## Open a new window in the current directory
bind C new-window -c "#{pane_current_path}"

## Vim style pane switching
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R

## Change window
bind -r Tab next-window

## Moving window
bind -n C-S-Left swap-window -t -1 \; previous-window
bind -n C-S-Right swap-window -t +1 \; next-window

## Split horizontal
unbind '"'
bind \\ split-window -h -c "#{pane_current_path}"

## Split vertical
unbind %
bind | split-window -v -c "#{pane_current_path}"

## Popups
### Open file-browser in current folder
bind o popup -h90% -w90% -E -d '#{pane_current_path}' "yazi"
### Open file-browser in $HOME folder
bind O popup -h90% -w90% -E -d $HOME "yazi"
### Open lazygit
bind g popup -d '#{pane_current_path}' -w80% -h80% -E lazygit
### Open private terminal
bind f popup -d '#{pane_current_path}' -w80% -h80% -E fish --private
### Open bottom 
bind b popup -w90% -h90% -E btm
### Open typing test
bind t popup -w30% -h50% -E -B ttyper --config $HOME/.config/ttyper/config.toml


if-shell "test -f $HOME/.config/tmux/custom.conf" {
  source-file $HOME/.config/tmux/custom.conf
}


# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run "$HOME/.config/tmux/plugins/tpm/tpm"
